Option Explicit
Dim doc
Set doc = application.ActiveDocument
GetUserLicence(doc)
main

' Function to validate document
Private Function ValidateServer(docObj)
    Dim key, licenseServer, licenseToken
    key = docObj.Validate(0)
    Set licenseServer = CreateObject("MGCPCBAutomationLicensing.Application")
    licenseToken = licenseServer.GetToken(key)
    Set licenseServer = nothing
    'On Error Resume Next
    Err.Clear
    docObj.Validate(licenseToken)
    If Err Then
        ValidateServer = 0    
    Else 
        ValidateServer = 1
    End If
End Function

sub GetUserLicence(docObj)

	If ValidateServer(docObj) = 0 Then
	    msgbox "Server validation failed."
	    exit sub
	End If
	
end sub

Sub SetClipboardText(Text)   '写入信息到剪切板
	dim wsShell
    Set wsShell = CreateObject("WScript.Shell")
    wsShell.Run "mshta vbscript:ClipboardData.SetData("&chr(34)&"text"&chr(34)&"," &Chr(34)& Text &Chr(34)& ")(close)",0,True
End Sub
'----------------------------------------------------------------

sub main()
	dim selNetnamelist
	selNetnamelist = ""
	
	dim pcbnets,pcbnet
	set pcbnets = doc.nets(1)
	for each pcbnet in pcbnets
		selNetnamelist = selNetnamelist & pcbnet.name  & " "
	next	
	selNetnamelist = left(selNetnamelist,len(selNetnamelist)-1)
	
	Dim Form, TextBox
	Set Form = CreateObject("Forms.Form.1") 
	Set TextBox = Form.Controls.Add("Forms.TextBox.1").Object 
	TextBox.MultiLine = True 
	TextBox.Text = selNetnamelist
	TextBox.SelStart = 0 
	TextBox.SelLength = TextBox.TextLength 	
	TextBox.Copy
	msgbox "done"
end sub
'====================================================

